package com.erpanderp.pr.model.entity

import com.erpanderp.pr.util.Constants

class PurchaseRequest {

	static belongsTo=[user:User]
	static hasMany=[purchaseRequestItems:PurchaseRequestItem,purchaseRequestTransactionViews:PurchaseRequestTransactionView,schedules:Schedule]

	String purchaseRequestCode
	String sapPrNumber
	String documentType
	String status
	String description
	
	Date dateCreated
	Date lastUpdated
	String createdBy
	String lastUpdatedBy

    static constraints = {
    	purchaseRequestCode(unique:true, maxSize:50)
    	sapPrNumber(nullable:true, maxSize: 255)
    	documentType(maxSize: 4)
    	description(maxSize: 1024)
    	createdBy(maxSize: 255)
    	lastUpdatedBy(maxSize: 255)
    	status(maxSize: 20, inList:[Constants.PURCHASE_REQUEST_STATUS_CREATED, Constants.PURCHASE_REQUEST_STATUS_UPLOADED, Constants.PURCHASE_REQUEST_STATUS_ACKNOWLEDGED])
    }
}
